<template>
  <div class="containerbox">
    <el-row class="searchbox" :gutter="20">
      <el-col :span="8">
        <el-input placeholder="请输入关键字查询" v-model="queryInfo.searchValue" class="input-with-select"
          suffix-icon="el-icon-search">
        </el-input>
      </el-col>
      <el-col :span="2">
        <el-button type="primary" @click="search" :style="{ height: '40px' }">搜索</el-button>
      </el-col>
    </el-row>
    <!-- <el-row class="draftTitle">
      <el-card>
        <div class="listtitle">
          <i></i>
          <div class="txt">已完结流程</div>
        </div>
      </el-card>
    </el-row> -->
    <!-- 列表区 -->
    <div class="draftlist">
      <div class="table" v-if="total !== 0">
        <div class="table-head">
          <div>序号</div>
          <div>标题</div>
          <div>发布时间</div>
          <div>来源</div>
          <div>类型</div>
          <div>操作</div>
        </div>

        <div class="content-container">
          <div v-for="(item, index) in waitList" :key="index">
            <div class="row">
              <div>{{ (index + 1).toString().padStart(2, '0') }}</div>
              <div class="title">
                <span @click="toggleOpen(item)" class="icon"
                  v-if="item.involvedPeopleList && item.involvedPeopleList.length">
                  <i class="el-icon-arrow-down" v-if="!openedId.includes(item.orderId)"></i>
                  <i class="el-icon-arrow-up" v-else></i>
                </span>
                {{ item.artTitle }}
              </div>
              <div>{{ item.artPublishTime }}</div>
              <div>{{ item.artSourceName === '其它' ? item.siteName : item.artSourceName }}</div>
              <div>{{ item.opinionTypeName }}</div>
              <div> <el-link @click="openOrder(item.orderId)" type="primary">查看</el-link></div>
            </div>
            <div class="involvedPeopleList-container" v-if="openedId.includes(item.orderId)">
              <div class="involvedPeopleList-head">
                <div>涉事人员姓名</div>
                <div>涉事人员类型</div>
                <div>学院</div>
                <div>工号/学号</div>
                <div>涉事人员性别</div>
                <div>辅导员教师</div>
                <div>心理问题</div>
                <div>政治身份</div>
                <div>民族</div>
                <div>宗教信仰</div>
              </div>
              <div class="involvedPeopleList-row" v-for="(ip, index) in item.involvedPeopleList || []" :key="index">
                <div>{{ ip.involvedpName }}</div>
                <div>{{ ip.involvedpType === "student" ? '学生' : '老师' }}</div>
                <div>{{ ip.involvedpSchool }}</div>
                <div>{{ ip.involvedpNumber }}</div>
                <div>{{ ip.involvedpSex === "male" ? '男' : '女' }}</div>
                <div>{{ ip.involvedpAdvisor }}</div>
                <div>
                  <span v-if="ip.psychologicalProblemsFlag === 0">否</span>
                  <span v-if="ip.psychologicalProblemsFlag === 2">暂不清晰</span>
                  <span v-if="ip.psychologicalProblemsFlag === 1">{{ ip.psychologicalProblems }}</span>
                </div>
                <div>
                  <span v-if="ip.politicalIdentityType === 1">党员（预备党员）</span>
                  <span v-if="ip.politicalIdentityType === 2">共青团员</span>
                  <span v-if="ip.politicalIdentityType === 3">群众</span>
                  <span v-if="ip.politicalIdentityType === 9">{{ ip.otherPoliticalIdentity }}</span>
                </div>
                <div>
                  <span>{{ ip.involvedpNation }}</span>
                </div>
                <div>
                  <span v-if="ip.religiousFaithFlag === 0">无</span>
                  <span v-if="ip.religiousFaithFlag === 1">{{ ip.religiousFaith }}</span>
                </div>

              </div>
            </div>
          </div>
        </div>
      </div>

      <el-row type="flex" align="middle" class="nodata-endlist" v-else>
        <el-col>
          暂无数据
        </el-col>
      </el-row>

      <div class="pagi">
        <BizPagination :total="total" :page.sync="queryInfo.pageNum" :limit.sync="queryInfo.pageSize"
          @pagination="getOpinionList" />

      </div>
    </div>
  </div>
</template>

<script>
import { getopinionlist } from '@/api/opinion/data';
import { parseTime } from '@/utils/ruoyi';
export default {
  data() {
    return {
      highlight: 3,
      searchKey: '',
      queryInfo: {
        searchValue: '',
        beginTime: '',
        endTime: '',
        searchType: 3,
        queryType: 3,
        pageNum: 1,
        pageSize: 10
      },
      total: -1,
      waitList: [],
      openedId: []
    };
  },
  watch: {
    'queryInfo.searchValue'() {
      if (this.queryInfo.searchValue == '') {
        this.getOpinionList();
      }
    }
  },
  created() {
    this.getOpinionList();
  },
  methods: {
    toggleOpen(row) {
      if (this.openedId.includes(row.orderId)) {
        this.openedId = this.openedId.filter(d => d !== row.orderId)
      } else {
        this.openedId.push(row.orderId)
      }
    },

    getOpinionList() {
      getopinionlist(this.queryInfo)
        .then(res => {
          if (res.code == 200) {
            this.total = res.total;
            const rows = this.setdraftList(res.rows);
            this.waitList = rows;
            console.log("rows", rows)
          }
        })
        .catch(() => {
          this.$message.error('获取待办列表失败');
        });
    },
    setdraftList(data) {
      data.forEach(item => {
        let time = item.artPublishTime;
        item.artPublishTime = parseTime(time);
      });
      return data;
    },
    openOrder(id) {
      this.$router.push('/waitDetail/' + id + '/' + this.queryInfo.searchType + '/' + this.highlight + '/0');
    },
    search() {
      this.queryInfo.pageNum = 1;
      this.getOpinionList();
    }
  }
};
</script>

<style lang="scss" scoped>
.containerbox {
  min-height: 85vh;
  background-color: rgb(240, 242, 245);
  padding: 15px;
}

.searchbox {
  margin: auto;
  margin-bottom: 20px;
}

.listtitle {
  margin-top: 15px;

  .txt {
    font-size: 16px;
    color: #333;
    font-weight: 600;
    display: inline-block;
    vertical-align: middle;
  }

  i {
    display: inline-block;
    width: 4px;
    height: 20px;
    background: #2d8cf0;
    vertical-align: middle;
    margin-right: 15px;
    margin-left: 3px;
  }
}

.el-card.is-always-shadow {
  box-shadow: none !important;
}

.draftTitle .el-card {
  border-radius: 0;
  border: none;
  border-bottom: 1px solid #ededf6 !important;
}

.draftlist {
  background: white;
  height: calc(100vh - 198px);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 24px;

  .table {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    .table-head {
      flex-shrink: 0;
      overflow: hidden;
      display: grid;
      grid-template-columns: 48px 3fr repeat(4, 1fr);
      gap: 8px;
      background: rgba(174, 183, 205, .15);
      height: 32px;
      line-height: 32px;
      color: rgba(129, 143, 172, 1);
      font-size: 14px;
      border-bottom: 1px solid rgba(129, 143, 172, 0.2);
      padding-left: 28px;
    }

    .content-container {
      flex: 1;
      overflow: auto;

      .row {
        height: 40px;
        background: #FFFFFF;
        border: 1px solid rgba(129, 143, 172, 0.2);
        border-top: none;
        line-height: 40px;
        display: grid;
        grid-template-columns: 48px 3fr repeat(4, 1fr);
        gap: 8px;
        color: #515B73;
        padding-left: 28px;
        font-size: 14px;

        >div {
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }

        .title {

          .icon {
            margin-right: 8px;
            cursor: pointer;
          }
        }
      }

      .involvedPeopleList-container {

        .involvedPeopleList-head {
          padding-left: 90px;
          padding-right: 30px;
          display: grid;
          // grid-template-columns: repeat(9, 1fr);
          grid-template-columns: repeat(7, 1fr) 1.5fr 1fr 1fr;
          gap: 4px;
          background: rgba(174, 183, 205, .15);
          height: 32px;
          line-height: 32px;
          color: rgba(129, 143, 172, 1);
          font-size: 14px;
        }

        .involvedPeopleList-row {
          padding-left: 90px;
          padding-right: 30px;
          display: grid;
          // grid-template-columns: repeat(9, 1fr);
          grid-template-columns: repeat(7, 1fr) 1.5fr 1fr 1fr;
          gap: 4px;
          min-height: 32px;
          line-height: 22px;
          font-size: 14px;
          border: 1px solid rgba(129, 143, 172, 0.2);

          div {
            display: flex;
            align-items: center;
          }

          &:nth-child(2n-1) {

            background: rgba(174, 183, 205, .15);
            border: none;
          }
        }
      }
    }
  }

  .pagi {
    flex-shrink: 0;
    display: flex;
    flex-direction: row-reverse;
    overflow: hidden;
  }
}
</style>
<style lang="scss">
.nodata-endlist {
  text-align: center;
  // height: 50vh;
  flex: 1;
  background-color: #fff;
  color: #515A6E;
  font-size: 18px;
  letter-spacing: 10px;
}

.searchbox {
  .el-input__inner {
    height: 40px !important;
    line-height: 40px !important;
  }

  .el-input-group__append {
    background-color: #4383e4 !important;
    color: #fff !important;
    font-size: 16px !important;
    border: 0 !important;
  }
}

.draftTitle {
  .el-card__body {
    padding: 10px 20px 20px 20px !important;
  }
}

.draftlist {
  .el-card {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #ededf6 !important;
  }

  .el-card__body {
    padding: 15px 20px 15px 20px !important;
  }
}

.txtcontent {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
</style>
